package com.freewater.javabase.demo.designpattern.command2.undowithstatus.receiver;

/**
 * Created by FreeWater on 2017/4/4.
 */
public class CellingFan {
	public static final int HIGH = 3;

	public static final int MEDIUM = 2;

	public static final int LOW = 1;

	public static final int OFF = 0;

	private String location;

	private int speed;

	public CellingFan(String location){
		this.location = location;
		this.speed = OFF;
	}

	public void high(){
		this.speed = HIGH;
		this.desc();
	}

	public void medium(){
		this.speed = MEDIUM;
		this.desc();
	}

	public void low(){
		this.speed = LOW;
		this.desc();
	}

	public void off(){
		this.speed = OFF;
		this.desc();
	}

	public int getSpeed(){
		return this.speed;
	}

	public void desc(){
		System.out.println(location + " celling fan is " + (speed == HIGH ? " on high " :
				(speed == MEDIUM ? " on medium " : (speed == LOW ? " on low " : " off"))));
	}
}
